#pragma once
/*
usage:
			 char  guid[64];
             CoInitialize(NULL);
			 GenerateGuid(guid);
			  printf(guid);
			  printf("\r\n");
			CoUninitialize();


*/
 void GenerateGuid(/*[in][out]*/char buf[64])
{
	GUID guid;
	if (S_OK == ::CoCreateGuid(&guid))
	{
		sprintf(buf
			, "{%08X-%04X-%04x-%02X%02X-%02X%02X%02X%02X%02X%02X}"
			, guid.Data1
			, guid.Data2
			, guid.Data3
			, guid.Data4[0], guid.Data4[1]
		, guid.Data4[2], guid.Data4[3], guid.Data4[4], guid.Data4[5]
		, guid.Data4[6], guid.Data4[7]
		);
	}

}
/*IsEqualGUID(CString )*/

 BOOL IsGUID(LPCTSTR lpStr)
{
	const size_t nLen = _tcslen(lpStr);
	return (nLen == 38) && (lpStr[0] == _T('{')) && (lpStr[37] == _T('}'));
}


 BOOL IsBeginGUID(LPCTSTR lpStr)
{
	const size_t nLen = _tcslen(lpStr);
	return (nLen >= 38) && (lpStr[0] == _T('{')) && (lpStr[37] == _T('}'));
}


 CString GetGUID(CString & strGUID)
{
	return strGUID.Left(38);
}


